﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<!--这meta的作用就是删除默认的苹果工具栏和菜单栏。-->
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!--在web app应用下状态条（屏幕顶部条）的颜色-->
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<!--该标签用于指定是否将网页内容中的手机号码显示为拨号的超链接。-->
<meta name="format-detection" content="telephone=no"/>
<!--网页在任何时候都不能被Cache存储-->
<meta http-equiv="Expires" content="-1"/>
<!--清除缓存-->
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Pragma" content="no-cache"/>
<title></title>
<link href="${ctx}/static/newweb/css/wt.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/static/newweb/css/top.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/static/newweb/css/footer.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="${ctx}/static/newweb/js/zepto.min.js"></script>
<script language="javascript" type="text/javascript" src="${ctx}/static/newweb/js/dropload.min.js"></script>
<script src="${ctx}/static/newweb/js/mdialog.js"></script>
<link href="${ctx}/static/newweb/css/dropload.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="${ctx}/static/newweb/css/mdialog.css"/>
<script src="${ctx}/static/newweb/js/main.js"></script>
<link rel="stylesheet" href="${ctx}/static/newweb/css/reset.css"/>
<link rel="stylesheet" href="${ctx}/static/newweb/css/style.css"/>
<script language="javascript" type="text/jscript">
function home(mid){
	window.location="${ctx}/wechatapi/personal?mid="+mid;
}
function del(){
	 $('.cd-popup').addClass('is-visible');
}
function ok(){
  $('.cd-popup').removeClass('is-visible');
  window.location='${ctx}/wechatapi/delAsk?id=${faq.id}';
}
function not(){
  $('.cd-popup').removeClass('is-visible');
}

//关注
function follow(){
	var fid = ${faq.id};
	var sum = $("#follow").html();
	$.ajax({
		type: 'POST',
		url: '${ctx}/wechatapi/follow',
		dataType: 'json',
		data:{
			id:fid,
			num:sum
		},
		success: function(data){
			new TipBox({
				type:'success',
				str:'操作成功',
				hasBtn:false,
				setTime:1000,
				callBack:function(){
					$("#follow").html(data);
					$("#wgz").css('display','block');
					$("#gz").css('display','none');
				}
			});
		}
	});	
}

//取消关注
function nofollow(){
	var fid = ${faq.id};
	var sum = $("#follow").html();
	$.ajax({
		type: 'POST',
		url: '${ctx}/wechatapi/noFollow',
		dataType: 'json',
		data:{
			id:fid,
			num:sum
		},
		success: function(data){
			new TipBox({
				type:'success',
				str:'操作成功',
				hasBtn:false,
				setTime:1000,
				callBack:function(){
					$("#follow").html(data);
					$("#wgz").css('display','none');
					$("#gz").css('display','block');
				}
			});
		}
	});	
}
</script>
</head>
<body>
<div class="top">
</div>
<%
  if (session.member.headimgurl == null){
%>
<img class="topone" src="${ctx}/static/newweb/img/wechat.png" onclick="home('${session.member.id}')"/>
<%
  }else{
%>
<img class="topone" src="${session.member.headimgurl!}46" onclick="home('${session.member.id}')"/>
<%
  }
%>
<div class="topbox"></div>
<div class="main"> 
	<div class="gr">
<%
  if (faq.img == null){
%>
<img src="${ctx}/static/newweb/img/wechat.png" onclick="home('${faq.mid}')"/>
<%
  }else{
%>
<img src="${faq.img!}46" onclick="home('${faq.mid}')"/>
<%
  }
%>
<%
  if (faq.typeid==1){
%>
<span>来自管理</span>
<%
  }else if(faq.typeid == 2){
%>
<span>来自财务</span>
<%
  }else if(faq.typeid == 3){
%>
<span>来自行政</span>
<%
  }else if(faq.typeid == 4){
%>
<span>来自业务</span>
<%
  }else{
%>
<span>来源未知</span>
<%
  }
%>
	</div>
	<h1>${faq.title!}</h1>
    <p>
    <%
      if (faq.content != null){
    %>
    ${strutil.replace(faq.content,'\n','<br/>')}
    <%
      }
    %>
    </p>
   <div class="kz">
   <%
      if (ishave==1){
   %>
        <img src="${ctx}/static/newweb/img/shanchu.png" onclick="del()"/>
        <img src="${ctx}/static/newweb/img/shuxie.png" onclick="toedit()"/>
   <%
     }
   %>
    </div>    
  <div class="bs"></div>
    
  <div class="gn">
        <img src="${ctx}/static/newweb/img/guanzhu.png" />
        <span id="follow">${faq.follow!}</span>
        <img src="${ctx}/static/newweb/img/pinglun.png" />
        <span>${faq.replys!}</span>
        <img src="${ctx}/static/newweb/img/dianzan.png" />
        <span>${faq.praise!}</span>
    </div>
  <div class="ans">
    <div class="gg">
      <span class="wgz" id="wgz" onclick="nofollow()">取消关注</span>
      <span class="gz"  id="gz"  onclick="follow()">关注</span>
    </div>
    <span class="xs" onclick="window.location='${ctx}/wechatapi/reply?id=${id!}'">回复</span>
  </div>
  <div class="clearfix"></div>
</div>
<div class="viewport">
<div class="main" id="main">
</div> 
</div>  

<div class="bottom"></div>
<div class="footer">
    <a href="${ctx}/wechatapi/portal" class="footerl"><img src="${ctx}/static/newweb/img/zhuye.png" /></a>
    <a href="${ctx}/wechatapi/search" class="footerr"><img src="${ctx}/static/newweb/img/sousuo.png" /></a>
</div>
<div class="fix">
<a href="${ctx}/wechatapi/ask">问</a>

</div>
<script language="javascript" type="text/jscript">
function toedit(){
	window.location='${ctx}/wechatapi/toEditAsk?id=${faq.id!}';
}
$(function(){
	if (${praise} == 1){
		$("#wgz").css('display','block');
		$("#gz").css('display','none');
	}else{
		$("#wgz").css('display','none');
		$("#gz").css('display','block');		
	}
	var sum = 0;
    var counter = 0;
    // 每页展示4个
    var num = 4;
    var pageStart = 0,pageEnd = 4;

    // dropload
    $('.viewport').dropload({
        scrollArea : window,
        domDown : {
            domClass   : 'dropload-down',
            domRefresh : '<div class="dropload-refresh">↓下拉加载更多</div>',
            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData  : '<div class="dropload-noData">加载完成</div>'
        },        
        loadDownFn : function(me){
            $.ajax({
                type: 'GET',
                url: '${ctx}/wechatapi/ajaxdetail?id=${id!}&pageCurrent='+(counter+1),
                dataType: 'json',
                success: function(data){
                	if (data.totalRow == 0){
                		$('.top').html('暂无回复');
                	}else{
                		$('.top').html('共'+data.totalRow+'个回复');
                	}
                        var result = '';
                        counter++;
                        for(var i = pageStart; i < pageEnd; i++){
                        	if (i <= data.pageData.length-1){
                        		sum++;
                        		var iurl = "";
                        		if (data.pageData[i].img == null){
                        			iurl="${ctx}/static/newweb/img/wechat.png";
                        		}else{
                        			iurl=data.pageData[i].img+'46';
                        		}
                        		var autograph="";
                        		if (data.pageData[i].autograph != null){
                        			autograph = data.pageData[i].autograph;
                        		}
                        		var content="";
                        		if (data.pageData[i].content!=null){
                        			if (data.pageData[i].content.length>=160){
                        				content=data.pageData[i].content.substring(0 , 160);
                        				content +='...';
                        			}else{
                        				content=data.pageData[i].content;
                        			}                           			
                        		}
                        		content = content.replace('\n','<br/>');
                                result +='<div>';
                                if (sum != 1){
                                	result +='<div class="bs"></div>';
                                }
                                result +='<div class="gr"><img src="'+iurl+'"  onclick="home(\''+data.pageData[i].mid+'\')"/>'
                                +'<span class="xm">'+data.pageData[i].nickname+'</span>'
                                +'<span class="gx">'+autograph+'</span></div>'
                                +'<p onclick="window.location=\'${ctx}/wechatapi/replydetail?id='+data.pageData[i].id+'\'">'+content+'</p>'
                                +'</div>';                        		
                        	}
                            if(sum == data.totalRow){
                            	counter = counter-1;
                                // 锁定
                                me.lock();
                                // 无数据
                                me.noData();
                                break;
                            }
                        }
                        // 为了测试，延迟1秒加载
                        setTimeout(function(){
                            $('#main').append(result);
                            // 每次数据加载完，必须重置
                            me.resetload();
                        },100);                		
                },
                error: function(xhr, type){
                    alert('Ajax error!');
                    // 即使加载出错，也得重置
                    me.resetload();
                }
            });
        }
    });		
});
</script>
<div class="cd-popup" role="alert">
	<div class="cd-popup-container">
		<p>你确定你要删除这个提问吗?</p>
		<ul class="cd-buttons">
			<li><a href="#" onclick="ok()">是</a></li>
			<li><a href="#" onclick="not()">否</a></li>
		</ul>
		<a href="#" class="cd-popup-close img-replace">关闭</a>
	</div> <!-- cd-popup-container -->
</div> <!-- cd-popup -->
</body>
</html>
